#include "Box.h"
#include "pal.h"
#include "pal/palFactory.h"
#include "pal/ConfigStatic.h"
namespace obstacles
{

Box::Box()
{
	position = new palVector3;
	size = new palVector3;
	size->x = 1.0;
	size->y = 1.0;
	size->z = 1.0;
	mass = 1;
}

Box::~Box()
{

}

palVector3 Box::getPosition()
{
	palVector3 pos;
	body->GetPosition(pos);
	return pos;
}

void Box::setPosition(float x, float y, float z)
{
	position->x = x;
	position->y = y;
	position->z = z;
}

void Box::createPhysics()
{
	body = PF->CreateBox(); //create a box
	body->Init(position->x, position->y, position->z, size->x, size->y, size->z, mass); //
}

int Box::getElementCount() {
	return 1;
}

ElementData Box::getElementData(int index) {
	ElementData ed(BoxType);
	float *d = new float[3];
	d[0] = size->x;
	d[1] = size->y;
	d[2] = size->z;
	ed.setData(3,d);
	ed.setColor(255,10,10);
	palMatrix4x4 loc = body->GetLocationMatrix();
	ed.setTransformationMatrix(loc._mat);
	return ed;
}

void Box::setScale(float x, float y, float z) {
	printf("new Size of box: %f %f %f \n", x, y ,z);
	size->x = x;
	size->y = y;
	size->z = z;
}

void Box::setMass(float mass) {
	this->mass = mass;
}
}

